# Mario Fireball - Variations using on the fly floating point changing

# To understand the code better, please read these guides!!
# Code's original article wizardry guide: https://docs.google.com/document/d/1lrd140BIUFApPFadD0yflsBuu8kS9Zm7WUULvdsWEAo/
# My on the fly article floating point changing guide: https://docs.google.com/document/d/1HkvrNNnZ-QnIp53EJlvBilzunm7lgHBtHCWAAKV9FKw/
# Also I wrote this for changing the bone an article is attached to, specifically because Mario's fireball can't be easily changed so I wanted to detail the hacky (but successful) way I use (which will also work for any other article that has this issue as far as I know, eliminating the need for a code): https://docs.google.com/document/d/11V88VjX-XZKshtSEVHA873e7mN6EY34uHAEajGouBHU/edit#heading=h.t68pre5kww5b


# B (1CE): Dr Mario's arc pill from Legacy, bounces on ground
# B air (1CF): Sends straight downwards
# Side B (1D0): Stays in place
# Side B air (1D1): Shoots straight forward, increases in speed every 30 frames 
# Note: Mario has memory for five fireball instances. That means five can be generated at a time. If a sixth is generated, it deletes the first. This does not mean you can only have five variations using this technique, but means you can only have five articles at most generated at one time. You have no control over which instance gets created at a time, but once it has been created you can use code to determine which article variation it should be.

######## 1CE, 1CF, 1D0, 1D1 (example below using 1CE) ########

# Stores a value in Fireball's LA-Basic[29]
# All five must be set, as you cannot control which instance of the fireball will be created
# In this example, the value of RA-Basic[10] is being stored, but you can use any VALUE.
Basic Variable Set: RA-Basic[30014] = RA-Basic[10]
Basic Variable Set: RA-Basic[32016] = RA-Basic[10]
Basic Variable Set: RA-Basic[34018] = RA-Basic[10]
Basic Variable Set: RA-Basic[36020] = RA-Basic[10]
Basic Variable Set: RA-Basic[38022] = RA-Basic[10]


# Creates on the fly attribute floating point table
# Corresponds with parameters tab in PSA Compressor for fireball article
# Values can be whatever you want
# To easily convert a float value to hex, use PSA Compressor's article parameters tab, enter your float, right click and hit "convert to hex"
Basic Variable Set: RA-Basic[11] = 3D9374BC
Basic Variable Set: RA-Basic[12] = 3FA00000
Basic Variable Set: RA-Basic[13] = 3F5EB852
Basic Variable Set: RA-Basic[14] = 3FB9999A
Basic Variable Set: RA-Basic[15] = 3F5F66F9
Basic Variable Set: RA-Basic[16] = 5A
Basic Variable Set: RA-Basic[17] = 0
Basic Variable Set: RA-Basic[18] = 400CCCCD

# This code updates the article's floating point table pointers
# This changes it from the old table to the newly created table (Starting at Mario's RA-Basic[11]
# This works by getting the value that stores the pointer to Mario's RA-Basic[0] (which is stored in RA-Basic[37]), offsetting it to reach RA-Basic[11], and then setting the pointer to it
# All five must be set, as you cannot control which instance of the fireball will be created 
Basic Variable Set: RA-Basic[19] = RA-Basic[37]
Basic Variable Add: RA-Basic[19] +- 2C
Basic Variable Set: RA-Basic[30536] = RA-Basic[19]
Basic Variable Set: RA-Basic[32538] = RA-Basic[19]
Basic Variable Set: RA-Basic[34540] = RA-Basic[19]
Basic Variable Set: RA-Basic[36542] = RA-Basic[19]
Basic Variable Set: RA-Basic[38544] = RA-Basic[19]

########

######## Article 1 (fireball) Action 0 ########

# LA-Basic[29] is currently set to whatever was given to it from the previous section (e.g. Basic Variable Set: RA-Basic[30014] = RA-Basic[10])
# We are now setting it to a new variable, LA-Basic[30].
# This is done to differentiate this article instance from the others to make sure the proper variation of the article can be compared against. Since we cannot control which instance of the article is loaded, LA-Basic[29] is set for all of them, however only the article instance will set its own LA-Basic[30], alleviating this issue.
# Long story short: do this if you want to have two or more article variations on screen at the same time, otherwise their code could conflict with each others
Basic Variable Set: LA-Basic[30] = LA-Basic[29]

# The other variables set here (LA-Basic[5] and LA-Basic[7] are used with the Side B air, which are used in order to increase the speed as frames pass. Since these are not specifically related to article wizardry, I am not going to explain them here. You will see how they are used in the next section.

########

######## Article 1 subactions (Main, GFX, SFX)

# These just go to subroutines where I use if statements against LA-Basic[30] to check which fireball variation to use code for (e.g. which hitboxes to load, which graphic effects to show)

########

######## Concurrent Infinite Loop (the one inside Action 0)

# This loop is ran every frame of the article's existence on a separate thread, meaning any other code is running in parallel
# The fireball used to use this loop to constantly check if fireball is touching a floor, wall or ceiling, and to bounce if so
# Now it is being used to allow each fireball variation to run its own code for what it should do as it exists/how it should be terminated
# Once again, LA-Basic[30] is used to check for which fireball variation to use code for

# LA-Basic[4] stores how many frames the fireball should last for. For all of the variations, it is decremented by 1, as all of them should disappear when time is up. If this function is not wanted, then this should be moved within the proper if statements
Basic Variable Decrement: LA-Basic[4]--

# If variation 0 (Dr Mario's bounce)...
# Bouncing requires Mario's fireball table to be read in again, only so it can read in the "Fireball bounce velocity multiplier" and multiply that against the fireball's speed.
# So I use the same technique for making the article table in Mario as I do inside this article's varibles and point it to this table, in order to free Mario's variables for use elsewhere. RA-Basic[25] to RA-Basic[32] in the variable are used since those seem to be free space
# RA-Basic[704] is where the pointer to the floating point table is located for the article, it is now updated to point to this newly created table
# "Enter Final Smash State" is what executes the fireball bounce. Idk wtf the 0A080000 does...but you can remove it and nothing seems to be changed...it's just what's in Mario's original fireball code
# LA-Basic[4] holds how many frames the article should last for, and it is decremented each time this loop is run, so if it hits 0, execute code before terminating it (in this case, a graphic effect is called before terminating the instance)
If Compare: LA-Basic[30] == 0.0
    If: Touching a Floor, Wall, or Ceiling,
        Basic Variable Set: RA-Basic[25] = 3D9374BC
        Basic Variable Set: RA-Basic[26] = 3FA00000
        Basic Variable Set: RA-Basic[27] = 3F5EB852
        Basic Variable Set: RA-Basic[28] = 3FB9999A
        Basic Variable Set: RA-Basic[29] = 3F5F66F9
        Basic Variable Set: RA-Basic[30] = 5A
        Basic Variable Set: RA-Basic[31] = 0
        Basic Variable Set: RA-Basic[32] = 400CCCCD
        Basic Variable Set: LA-Basic[6] = RA-Basic[8]
        Basic Variable Add: LA-Basic[6] +- 64
        Basic Variable Set: RA-Basic[704] = LA-Basic[6]
        Enter Final Smash State:
        Sub Routine: 2xC558,
        0A080000:
    End If:
    If Compare: LA-Basic[4] <= 0.0
        Graphic Effect (Detached): File #=0, Graphic=3, Bone=0, Z Offset=0.0, Y Offset=0.0, X Offset=0.0, Z Rotate=0.0, Y Rotate=0.0, X Rotate=0.0, Size=1.0, Random Z Offset=0.0, Random Y Offset=0.0, Random X Offset=0.0, Random Z Rotate=0.0, Random Y Rotate=0.0, Random X Rotate=0.0, Terminate With Animation=false
        Terminate Instance:
    End If:

# Else if variation 1 (Sends straight downwards)
# Nothing too crazy here, terminating instance when it runs out of time or hits a floor, wall, or ceiling
Else If Comparison Compare: LA-Basic[30] == 1.0
    If: Touching a Floor, Wall, or Ceiling,
        Or Comparison Compare: LA-Basic[4] <= 0.0
        Graphic Effect (Detached): File #=0, Graphic=2E, Bone=0, Z Offset=0.0, Y Offset=0.0, X Offset=0.0, Z Rotate=0.0, Y Rotate=0.0, X Rotate=0.0, Size=1.0, Random Z Offset=0.0, Random Y Offset=0.0, Random X Offset=0.0, Random Z Rotate=0.0, Random Y Rotate=0.0, Random X Rotate=0.0, Terminate With Animation=false
        Terminate Instance:
    End If:

# Else if variation 2 (Stays in place)
# Once again, nothing crazy here, terminate after running out of time
Else If Comparison Compare: LA-Basic[30] == 2.0
    If Compare: LA-Basic[4] <= 0.0
        Graphic Effect (Detached): File #=0, Graphic=37, Bone=0, Z Offset=0.0, Y Offset=0.0, X Offset=0.0, Z Rotate=0.0, Y Rotate=0.0, X Rotate=0.0, Size=1.0, Random Z Offset=0.0, Random Y Offset=0.0, Random X Offset=0.0, Random Z Rotate=0.0, Random Y Rotate=0.0, Random X Rotate=0.0, Terminate With Animation=false
        Terminate Instance:
    End If:

# Else if variation 3 (Shoots straight forward, increases in speed every 30 frames)
# The most complicated one, but not much different than the first variation (Dr Mario's Pill arc from Legacy). The only real difference is that instead of bouncing, we are using the bounce functionality purely to reload the table
# Remember, table is reloaded on bounce ("Enter Final Smash State" is what executes the bounce), which reloads in the value for "Fireball bounce velocity multiplier"
# This code, upon LA-Basic[5] reaching 30 (it increments by 1 every loop), will change the "Fireball bounce velocity multiplier" variable (RA-Basic[27] holds that value), and changes it before the bounce is called.
# This article has no gravity and is shooting straight forward -- not sure if this is necessary for this to work, but as of now the "Enter Final Smash State" will not bounce it off anything, and instead will just read in and apply the new "Fireball bounce velocity multiplier" parameter, thus speeding it up.
# LA-Basic[7] is set to the floating point hex value for 1 in Action 0 of the fireball article, then increased by 400000 (which is .5 in floating point) each time 30 ticks has hit.
Else If Comparison Compare: LA-Basic[30] == 3.0
    Basic Variable Add: LA-Basic[5] +- 1
    If Compare: LA-Basic[5] == 30.0
        Basic Variable Add: LA-Basic[7] +- 400000
        Basic Variable Set: RA-Basic[25] = 0
        Basic Variable Set: RA-Basic[26] = 3FA00000
        Basic Variable Set: RA-Basic[27] = LA-Basic[7]
        Basic Variable Set: RA-Basic[28] = 3FB33333
        Basic Variable Set: RA-Basic[29] = 0
        Basic Variable Set: RA-Basic[30] = 100
        Basic Variable Set: RA-Basic[31] = 0
        Basic Variable Set: RA-Basic[32] = 40800000
        Basic Variable Set: LA-Basic[6] = RA-Basic[8]
        Basic Variable Add: LA-Basic[6] +- 64
        Basic Variable Set: RA-Basic[704] = LA-Basic[6]
        Enter Final Smash State:
        Graphic Effect (Detached): File #=0, Graphic=16, Bone=0, Z Offset=0.0, Y Offset=0.0, X Offset=0.0, Z Rotate=0.0, Y Rotate=0.0, X Rotate=0.0, Size=1.0, Random Z Offset=0.0, Random Y Offset=0.0, Random X Offset=0.0, Random Z Rotate=0.0, Random Y Rotate=0.0, Random X Rotate=0.0, Terminate With Animation=false
        Basic Variable Set: LA-Basic[5] = 0
    End If:
    If: Touching a Floor, Wall, or Ceiling,
        Or Comparison Compare: LA-Basic[4] <= 0.0
        Graphic Effect (Detached): File #=0, Graphic=2C, Bone=0, Z Offset=0.0, Y Offset=0.0, X Offset=0.0, Z Rotate=0.0, Y Rotate=0.0, X Rotate=0.0, Size=1.0, Random Z Offset=0.0, Random Y Offset=0.0, Random X Offset=0.0, Random Z Rotate=0.0, Random Y Rotate=0.0, Random X Rotate=0.0, Terminate With Animation=false
        Terminate Instance:
    End If:

########

# That should be everything!